package com.topwalk.datacollect.dao.imp;

import com.topwalk.datacollect.dao.TZcMtpDtpTaskDao;
import com.topwalk.datacollect.enumI.ServerEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

@Repository
public class TZcMtpDtpTaskDaoImpl implements TZcMtpDtpTaskDao {
    @Autowired
    private JdbcTemplate jdbcTemplate;


    @Override
    public List<Map<String, Object>> findDeviceIdByTaskId(String api, String taskId) {
        ServerEnum serverEnum = ServerEnum.getTypeByServerCode(api);
        String sql = "";
        switch (serverEnum){
            case VIDEO:
                sql = "select FLD_DEVICE_ID deviceID from t_zc_mtp_task where FLD_ID = ?";
                break;
            case DBEXCHANGELOG:
            case FILEEXCHANGELOG:
                sql = "select deviceid deviceID from t_zc_dtp_task where taskid = ?";
                break;
        }

        return jdbcTemplate.queryForList(sql,taskId);
    }
}
